﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;


namespace Delay
{


    public class FoodTemplateSelector : DataTemplateSelector
    {
        public DataTemplate Head
        {
            get;
            set;
        }

        public DataTemplate Main
        {
            get;
            set;
        }

        public DataTemplate Tail
        {
            get;
            set;
        }
        
        public DataTemplate Title
        {
            get;
            set;
        }
        public DataTemplate LastTitle
        {
            get;
            set;
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {

            if (item is  PhoneInfoCenterItem)
              {
                  PhoneInfoCenterItem foodItem = item as PhoneInfoCenterItem;
                  if (foodItem != null)
                  {
                      if (foodItem.Type == "Head")
                      {
                          return Head;
                      }
                      else if (foodItem.Type == "Main")
                      {
                          return Main;
                      }
                      else if (foodItem.Type == "Tail")
                      {
                          return Tail;
                      }
                      else if (foodItem.Type == "Title")
                      {
                          return Title;
                      } 
                      else
                      {
                          return LastTitle;
                      }
                  }
              }
            else if (item is TypeCommentItem)
            {
                 TypeCommentItem commentItem = item as TypeCommentItem;
                if (commentItem != null)
                {
                    if (commentItem.Type == "Head")
                    {
                        return Head;
                    }
                    else if (commentItem.Type == "Main")
                    {
                        return Main;
                    }
                    else if (commentItem.Type == "Tail")
                    {
                        return Tail;
                    }
                    else
                    {
                        return Title;
                    }
                }//PhonePkDetail
                else if (item is PhonePkDetailItem)
                {
                    PhonePkDetailItem PkItem = item as PhonePkDetailItem;
                    if (PkItem != null)
                    {
                        if (PkItem.Type == "Head")
                        {
                            return Head;
                        }
                        else if (PkItem.Type == "Main")
                        {
                            return Main;
                        }
                        else if (PkItem.Type == "Tail")
                        {
                            return Tail;
                        }
                        else
                        {
                            return Title;
                        }
                    }//PhonePkDe
                }             
            }
            else if(item is TypeAreaItem)
            {
                TypeAreaItem AreaItem = item as TypeAreaItem;
                if (AreaItem != null)
                {
                    if (AreaItem.Type == "Head")
                    {
                        return Head;
                    }
                    else if (AreaItem.Type == "Main")
                    {
                        return Main;
                    }
                    else if (AreaItem.Type == "Tail")
                    {
                        return Tail;
                    }
                    else
                    {
                        return Title;
                    }
                }
            }
           
            else if (item is phonePkItem)
            {
                phonePkItem sr = item as phonePkItem;
                if (sr != null)
                {
                    if (sr.Type == "Head")
                    {
                        return Head;
                    }
                    else if (sr.Type == "Main")
                    {
                        return Main;
                    }
                    else if (sr.Type == "Tail")
                    {
                        return Tail;
                    }
                    else
                    {
                        return Title;
                    }
                }
            }
            else if (item is PhonePkDetailItem)
            {
                PhonePkDetailItem pdi = item as PhonePkDetailItem;
                if (pdi != null)
                {
                    if (pdi.Type == "Head")
                    {
                        return Head;
                    }
                    else if (pdi.Type == "Main")
                    {
                        return Main;
                    }
                    else if (pdi.Type == "Tail")
                    {
                        return Tail;
                    }
                    else
                    {
                        return Title;
                    }
                }
            }
            //userTable
            else if (item is userTable)
            {
                userTable pdi = item as userTable;
                if (pdi != null)
                {
                    if (pdi.Type == "Head")
                    {
                        return Head;
                    }
                    else if (pdi.Type == "Main")
                    {
                        return Main;
                    }
                    else if (pdi.Type == "Tail")
                    {
                        return Tail;
                    }
                    else
                    {
                        return Title;
                    }
                }
            }
            else if (item is ShowDownloadItem)
            {
                ShowDownloadItem pdi = item as ShowDownloadItem;
                if (pdi != null)
                {
                    if (pdi.Type == "Head")
                    {
                        return Head;
                    }
                    else if (pdi.Type == "Main")
                    {
                        return Main;
                    }
                    else if (pdi.Type == "Tail")
                    {
                        return Tail;
                    }
                    else
                    {
                        return Title;
                    }
                }
            }
            return base.SelectTemplate(item, container);
        }
    }
}
